﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ExcelExportLib
{
    public class ExcelCellCommentLineElement
    {
        public bool Bold=false;
        public bool Underline=false;
        public bool Italic=false;

        public string text;

        public ExcelCellCommentLineElement(string text)
        {
            this.text = text;
        }

        public override string  ToString()
        {
            string tmp=text;
            if(Bold) tmp="<B>"+tmp+"</B>";
            if(Underline) tmp="<U>"+tmp+"</U>";
            if(Italic) tmp="<I>"+tmp+"</I>";

 	        return tmp;
        }
    }

    /// <summary>Comment line</summary>
    /// <remarks>Saving with xml.WriteRaw so special characters like '&' can cause error on openning document in excel</remarks>
    public class ExcelCellCommentLine
    {
        public List<ExcelCellCommentLineElement> commentLineElements = new List<ExcelCellCommentLineElement>();

        public ExcelCellCommentLine(string text)
        {
            commentLineElements.Add(new ExcelCellCommentLineElement(text));
        }

        public ExcelCellCommentLineElement AddElement(string text)
        {
            commentLineElements.Add(new ExcelCellCommentLineElement(text));
            return commentLineElements[commentLineElements.Count - 1];
        }
        public ExcelCellCommentLineElement AddElement(string text, bool Bold)
        {
            commentLineElements.Add(new ExcelCellCommentLineElement(text));
            ExcelCellCommentLineElement ret = commentLineElements[commentLineElements.Count - 1];
            ret.Bold = Bold;
            return ret;
        }
        public ExcelCellCommentLineElement AddElement(string text, bool Bold, bool Italic)
        {
            commentLineElements.Add(new ExcelCellCommentLineElement(text));
            ExcelCellCommentLineElement ret = commentLineElements[commentLineElements.Count - 1];
            ret.Bold = Bold;
            ret.Italic = Italic;
            return ret;
        }
        public ExcelCellCommentLineElement AddElement(string text, bool Bold, bool Italic, bool Underline)
        {
            commentLineElements.Add(new ExcelCellCommentLineElement(text));
            ExcelCellCommentLineElement ret = commentLineElements[commentLineElements.Count - 1];
            ret.Bold = Bold;
            ret.Italic = Italic;
            ret.Underline = Underline;
            return ret;
        }

        public override string ToString()
        {
            string tmp = "";
            foreach (ExcelCellCommentLineElement cle in commentLineElements)
                tmp += cle.ToString();

            return tmp;
        }
    }
}
